﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using IDML.BusinessObject;
using IDML.BusinessLogic;


namespace IDML.Web
{
    public partial class Login1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.QueryString["Mode"] != null)
            {
                Session.Clear();
            }

            this.lblError.Text = string.Empty;

        }     

        protected void btnLogin_Click(object sender, EventArgs e)
        {
            try
            {
                string userName = null;
                string password = null;
                userName = txtUserName.Text;
                password = txtPassword.Text;
                UserBO b = new UserBO();
                b.UserName = userName;
                b.Password = password;
                IDMLSession i = new IDMLSession();
                UserBL user = new UserBL();
                i.User = user.GetUser(b);
                if (i.User != null)
                {
                    Response.Redirect("Default.aspx", false);
                }

                else
                {
                    throw new Exception("The user name or password provided is incorrect.");
                }
            }
            catch (Exception ex)
            {
                this.lblError.Text = ex.Message;
            }

        }



    }
}